extensions.org.icongarden.http.writeASCII ("Content-type: text/html\r\n\r\n");
var writeUTF8 = extensions.org.icongarden.http.writeUTF8;

try
{
	var fs = extensions.org.icongarden.fileSystem;

	workingDirectory = fs.getWorkingDirectory ( );

	function traverse (directoryEntries)
	{
		writeUTF8 ('<ul>');
		for (var directoryEntryIndex in directoryEntries)
		{
			var directoryEntry = directoryEntries [directoryEntryIndex];
			writeUTF8 ("<li>'" + directoryEntry.name + "' is a " + directoryEntry.type + " whose inode is " + directoryEntry.inode + "</li>");
	
			if (directoryEntry.type == 'directory')
			{
				writeUTF8 ('<blockquote>');
				traverse (directoryEntry.children);
				writeUTF8 ('</blockquote>');
			}
		}
		writeUTF8 ('</ul>');
	}

	workingDirectory = fs.getWorkingDirectory ( );	

	var beforeEnumerate = new Date ( );
	var directories = fs.enumerateDirectory (workingDirectory,true);
	var afterEnumerate = new Date ( );

	var beforeEncode = new Date ( );
	var json = extensions.org.icongarden.json.encode (directories);
	var afterEncode = new Date ( );

	writeUTF8 (json + '<hr>');

	var beforeDecode = new Date ( );
	var decodedJSON = extensions.org.icongarden.json.decode (json);
	var afterDecode = new Date ( );

	traverse (decodedJSON);

	writeUTF8 ('<hr>');

	writeUTF8 ("<p>milliseconds to enumerate: " + (afterEnumerate.getTime ( ) - beforeEnumerate.getTime ( )) + "</p>");
	writeUTF8 ("<p>milliseconds to encode: " + (afterEncode.getTime ( ) - beforeEncode.getTime ( )) + "</p>");
	writeUTF8 ("<p>milliseconds to decode: " + (afterDecode.getTime ( ) - beforeDecode.getTime ( )) + "</p>");
}
catch (e)
{
	writeUTF8 (e);
}
